function dfs(path = [], arr = [], start, target) {
    if (target === path.length) {
        ans1.push(path.slice(0));
        return;
    }
    for (let i = start; i < arr.length; i++) {
        path.push(arr[i]);
        // 深度查找
        dfs(path, arr, i + 1, target);
        path.pop(); // 回溯
    }
}

/**
 * dfs深度优先+回溯
 *             ——-
 *     /  /  |  |  | \  \
 *     1  2  3  4  5  6  7
 *   /  \ 
 *   2  3
 */


let ans1 = [];
function getSunArrs(arr = [], target) {
    let path = [];
    if (!arr.length) {
        return;
    }
    dfs(path, arr, 0, target);
    console.log("结果为：", ans1);
}
getSunArrs([1, 2, 3, 4, 5, 6, 7], 6);